<!-- components/evaluate-components/index.wxml -->
<template>
	<view class="evaluateBox ">
		<view class="lists" v-if="listData.length > 0">
			<block v-for="(item, index_) in listData" :key="index_">
				<view class="comment-item-box middle  animation-slide-bottom "
					:style="[{animationDelay:index_*0.1+'s'}]">
					<view class="cu-item comment-head vcenter ">
						<view class="cu-avatar round lg" :style="[{backgroundImage:'url('+item.user.headimgurl+')'}]">
						</view>
						<view class="comment-head-title">
							<view class="user-name text-xxl ">{{item.user.nickname}} <text
									class="time guanzhu">{{ item.created_at }}</text></view>
							<view class="text-gray text-sm flex comment-data ">
								<view class="stars ">
									<view class="stars-normal">
										<view class="box">
											<block v-for="i_ in 5" :key="i_"><text
													class="iconfont icon-xingxing"></text></block>
										</view>
									</view>
									<view class="stars-selected"
										:style="{ width: (item.service_rank / 5) * 100 + '%' }">
										<view class="box ">
											<block v-for="j_ in 5" :key="j_"><text
													class="iconfont icon-xingxing"></text></block>
										</view>
									</view>

								</view>

							</view>
						</view>
					</view>

					<view class="coment-content ">

						{{ item.content || '这位客官未发表任何看法' }}
					</view>

					<view class="imgs" v-if="item.img" style="max-height: 450rpx;">
					 <scroll-view scroll-y="true" class="img-scroll" >
						<view class="imgbox ">
							<image mode="aspectFill" :class="item.img.length>1?'picBox':'picBoxNo'" 
								v-for="(imgurl,key) in item.img" :key="key" :src="imgurl" @click="previewImg(imgurl,item.img)">
							</image>
						</view>
					 </scroll-view> 
						
					</view>


					<view class="evaluate-content1" v-if="item.reply">
						<view><text style="font-weight: bold;">回复：</text><text style="color: #777777;opacity: 0.9;">{{ item.reply.content || '商家还未回复~' }}</text>
						</view>
						<view class="imgs" v-if="item.reply.reply_img">
							<view class="imgbox ">
								<image mode="aspectFill" :class="item.reply.reply_img.length>1?'picBox':'picBoxNo'" 
									v-for="(imgurl, index) in item.reply.reply_img" :key="key" :src="imgurl" @click="previewImg(imgurl,item.img)">
								</image>
							</view>
							
						</view>
					</view>


				</view>


			</block>

			<view class="foot">

			</view>
		</view>

		<view class="no-lists" v-else>暂无评论</view>
	</view>
</template>

<script>
	//数据模拟
	import data from './list.js';
	export default {
		props: {
			//评价列表数据
			listData: {
				type: Array,
				default: data
			},
			//是否显示总评价数量
			isShowTotal: {
				type: Boolean,
				default: true
			},
			//是否显示评价前面的图标
			isShowIcon: {
				type: Boolean,
				default: true
			},
			//总评分
			rate: {
				type: Number,
				default: 4.6
			}
		},
		data() {
			return {}
		},
		methods: {
			previewImg(src, urls) {
				uni.previewImage({
					current: src,
					urls
				})
			}
		}
	};
</script>
<style scoped>
	@import './iconfont.css';

	.evaluateBox {
		width: 100%;
		margin-bottom: 120upx;
	}

	.item {
		display: flex;
		flex-direction: column;
	}

	.evaluate-header-title {
		width: 80%;
		height: 100%;
		display: flex;
		flex-direction: column;
	}

	.name-time {
		height: 50%;
	}

	.evaluate-header {
		width: 100%;
		height: 80upx;
		display: flex;
		flex-direction: row;

		padding: 20upx;
		align-items: center;
		margin-bottom: 12upx;
		box-sizing: border-box;
		border-bottom: 1upx solid #e5e5e5;
	}

	.evaluateBox .title {
		display: flex;
		align-items: center;
		color: #000000;
		font-size: 30upx;
	}

	.total {
		/* flex: 1; */
		height: 100%;
		font-size: 30upx;
		color: #d76d9d;
		display: flex;
		align-items: center;
		justify-content: flex-end;
	}

	.stars {
		width: 180upx;
		height: 36upx;
		display: flex;
		align-items: center;
		position: relative;
		line-height: 1;
	}

	.stars .box {
		width: 180upx;
		display: flex;
		align-items: center;
	}

	.stars-normal {
		width: 100%;
		position: absolute;
		left: 0;
		top: 0;
		color: #ccc;
		display: flex;
		align-items: center;
	}

	.stars-selected {
		position: absolute;
		left: 0;
		top: 0;
		z-index: 1;
		color: #fde16d;
		overflow: hidden;
		display: flex;
		align-items: center;
	}

	.stars-selected .iconfont,
	.stars-normal .iconfont {
		font-size: 28upx;
	}

	.lists .item {
		padding: 20upx;
		display: flex;
		font-size: 22upx;
		color: #999;
	}

	.lists .item .icon {
		width: 60upx;
		height: 60upx;
		border-radius: 50%;
		overflow: hidden;
		margin-right: 26upx;
		/* align-self: flex-start; */
	}

	.lists .item .info {
		flex: 1;
		font-size: 26upx;
		color: #666;
	}

	.info .name-time {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.info .name-time .time {
		font-size: 24rpx;
	}

	.lists .info .stars {
		width: 160rpx;
	}

	.info .stars-normal .iconfont,
	.info .stars-selected .iconfont {
		font-size: 28upx;
	}

	.info .stars .box {
		width: 160upx;
	}

	.lists .info .evaluate-content {
		color: #000;
		font-size: 28upx;
		text-align: left;
		padding-top: 6upx;
	}

	.evaluate-content1 {
		width: 92%;
		margin-top: 20upx;
		padding: 10upx 15upx 15upx 15upx;
		background: #F7F7F7;
		border-radius: 10upx;
	}

	.imgs {
		width: 96%;
		margin-top: 20rpx;
	}

	.info .evaluate-content .imgs {
		display: flex;
		flex-wrap: wrap;
		padding-top: 6upx;
	}

	.evaluate-content .imgs .imgs-box {
		width: 25%;
		padding-right: 10upx;
		box-sizing: border-box;
	}
	.no-lists {
		padding: 20upx 0;
		text-align: center;
		font-size: 24upx;
		color: #666;
	}



	.comment-item-box {
		width: 100%;
		padding: 30upx 0 30upx 0;
		/* max-height: 730upx; */
		background: #FFFFFF;
		box-shadow: 0px 0px 10upx 0px rgba(0, 0, 0, 0.05);
		border-radius: 20upx;
		flex-direction: column;
		margin-top: 15upx;

	}

	.imgbox {
		margin-top: 1vh;
		width: 100%;
		max--height: 300upx;
	}

	.vcenter {
		display: flex;
		align-items: center;
	}

	.comment-head {
		margin-top: 2%;
		height: 90upx;
		width: 94%;
		position: relative;

	}

	.coment-content {
		margin-top: 2%;
		width: 92%;
		margin-left: 4%;
		max-height: 400upx;
		font-size: 24pux;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: normal;
	
	}

	.comment-foot {
		margin-top: 2%;
		width: 94%;
		height: 20%;
		display: flex;
		position: relative;
		flex-direction: row;
		align-items: center;
	}

	.Enviro .imgs .imgs-box {
		width: 28vw;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
		margin-right: 15rpx;
	}

	.Enviro .imgs .imgs-box image {
		width: 100%;
		height: 28vw;
		-webkit-border-radius: 20rpx;
		border-radius: 20rpx;
	}

	.comment-head-title {
		height: 100%;
		width: 90%;
		margin-left: 2%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		text-align: left;
	}

	.user-name {
		width: 100%;
		font-size: 32upx;
		font-weight: 800;
		color: #333333;
		height: 50%;
		position: relative;
	}

	.comment-data {
		width: 100%;
		height: 50%;
		display: flex;
		align-items: center;
	}

	.comment-foot-tag {
		font-size: 24upx;
		background: #DBEBFF;
		font-weight: 500;
		color: #1270E0;
		max-width: 50%;
		overflow: auto;
		text-overflow: ellipsis;
		white-space: nowrap;

	}

	.comment-foot-right {
		position: absolute;
		float: right;
		right: 0;
		display: flex;
		flex-direction: row;
	}

	.comment-foot-icon {
		height: 100%;
		display: flex;
		font-size: 45upx;
		color: #DBDBDB;
	}

	.comment-foot-num {
		height: 100%;
		font-size: 28upx;
		margin: 10upx 5upx 0 5upx;
		font-weight: 500;
		color: #333333;
	}

	.guanzhu {
		font-size: 20upx;
		font-weight: 500;
		color: #999999;
		position: absolute;
		float: right;
		right: 0;
	}
	.img-scroll{
		max-height: 450rpx;
	}
	.imgbox {
		display: flex;
		flex-wrap: wrap;
	
	}
</style>
<style lang="scss">
	$width:(750*0.94*0.92-30)/3;
	$imgW:(750*0.94*0.08)/2;


	.imgbox {
		padding-left: $imgW+upx;
		width: 100%;

	}

	.picBox {
		width: $width+upx;
		height: $width+upx;
		border-radius: 20upx;
		object-fit: cover;
		margin: 0upx 10upx 10upx 0upx;
	}

	.picBoxNo {
		max-width: 750*0.94-20+upx;
		max-height: 400upx;
		border-radius: 20upx;
		object-fit: cover;
		margin: 10upx 0upx 10upx 0upx;
	}
	
	</style>
